<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>数据字典展示</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
	<div class="searchArea">
	    <!-- 查询表单 -->
	    <form id="searchBar">
	        <div class="fieldset1 clearFix">
	        	<div class="fieldBox">
	                <div class="label">所属系统</div>
	                <div class="field">
	                    <select name="searchSysCd" id="searhcSysCdId">
	                        <c:forEach items="${sysCdList }" var="sysCdTemp">
	                        	<option value="${sysCdTemp.key }">${sysCdTemp.value }</option>
	                        </c:forEach>
	                    </select>
	                </div>
	            </div>
	            <div class="fieldBox">
	                <div class="label">代码组值</div>
	                <div class="field">
	                	 <select name="codeGrpCd" id="cacheCodeGrpCdId" data-value="" validate="{select: true}">
				            <option value=" " checked >请选择</option>
				         </select>
	                </div>
	            </div>
				<div class="fieldBox">
					<div class="label">代码组名</div>
					<div class="field">
						<input type="text" id="codeGrpNm" name="codeGrpNm" class="ui-textbox" ligerui="width: 160" value="">
					</div>
				</div>
	            
	            <div class="clearFix"></div>
	            <div class="btnsBox formBtns notRight">
	               <span id="searchBtn" class="sq-button-round">查询</span>
				   <span id="clearBtn" class="sq-button-round">清空</span>
	               <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
	            </div>
	        </div>
	    </form>
	</div>
    <!-- 列表显示块 -->
	<div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
	var grid = null;
	$(function () {
		initForm();//初始化表单
	    initGrpCdList();//初始化下拉框
		initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
	    searchBtnEvent();//查询按钮事件
	    clearBtnEvent();//清空按钮事件
	});
	
	//初始化表单
	function initForm(){
		$("#searchBar").ligerForm();
	}
	
	//初始化下拉框
	function initGrpCdList(){
		 var _url = "<%=path%>/comm/dictionary/initList.do";
		 var form = new liger.get("searchBar");
         var data = form.getData();
         data.page = 1;
         data.pagesize = 1000;
         AjaxUtils.ajaxGet(_url, data, initCallback, true);
	}
	
	//初始化下拉框回调
	function initCallback(msg){
		$.each(msg.rows,function(index,obj) {
			var option = "<option value='"+obj.codeGrpCd+"'>"+ (obj.codeGrpCd +"-"+ obj.codeGrpNm) +"</option>";
			$(option).appendTo("#cacheCodeGrpCdId");
		});
		liger.get("cacheCodeGrpCdId").setSelect();
		$("#cacheCodeGrpCdId").add_ligerFormEditor();
	}
	
	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
		var data = form.getData();
		return data;
	}
	
	//初始化列表
	function initGrid(){
		$("#ligergrid1").ligerGrid({
			url:'<%=path%>/comm/dictionary/initListInfo.do',
			method:'get',
			parms:getSearchParams(),
			columns:[
				{ display: '系统代码', name: 'sysCd', width: 100 , align:'center', enabledSort:true},
				{ display: '组织架构代码', name: 'orgCd', width: 100 , align:'center', enabledSort:true},
				{ display: '代码组值', name: 'codeGrpCd', width: 100 , enabledSort:true},
				{ display: '代码组名', name: 'codeGrpNm', minWidth: 150 , enabledSort:true},
				{ display: '代码值', name: 'code', width: 100, align:'center', enabledSort:true},
				{ display: '代码名', name: 'codeNm', minWidth: 100, align:'center', enabledSort:true},
				{ display: '代码说明', name: 'codeDesc', minWidth: 120, align:'center', enabledSort:true},
				{ display: '代码序号', name: 'sortNo', width: 80, align:'center', enabledSort:true}
			],
			pageSize:10,
			root:'rows',
			record:'total',
			hideLoadButton:false,
			width:'100%',
			height:'100%',
			heightDiff:-2,
			checkbox:true,//列表是否有选择框
			rownumbers:true//列表是否有行号
		});
		grid = liger.get("ligergrid1");
		grid.setHeight(100);
		grid.options.isSingleCheck = true;//列表是否为单选
	}
	
	//查询按钮事件
	function searchBtnEvent(){
		$("#searchBtn").click(function(event) {
			var form = new liger.get("searchBar");
			var data = form.getData();
			for (name in data){
				grid.setParm(name,data[name]);
			};
			grid.reload();
		});
	}
	
	//清空按钮事件
	function clearBtnEvent(){
		$("#clearBtn").click(function(event) {
	        $("#resetBtn").click();  //重置 input-text
	        var form = liger.get("searchBar");
			form.setData({  //重置select等特殊表单
				"searchSysCd":"",
				"codeGrpCd":" "
			});
	    });
	}
</script>
</body>
</html>